/**
 * @description 导出默认网路配置
 **/
const baseURL = 'https://wemall-bloomagebiotech-api.bmjihuo.com'
const testBaseUrl = `http://176.122.172.18:9011`
function getBaseUrl() {
  console.log(process.env.NODE_ENV, 'process.env.NODE_ENV')
  try {
    if (process.env.NODE_ENV === 'development' || !window.location.href.startsWith('http')) {
      return testBaseUrl
    }
    if (process.env.NODE_ENV !== 'development' && baseURL.indexOf(window.location.host) > -1) {
      return baseURL
    } else {
      return `${window.location.protocol}//${window.location.host}` || testBaseUrl
    }
  } catch (e) {
    //TODO handle the exception
    return testBaseUrl
  }
}
const network = {
  // 默认的接口地址 如果是开发环境和生产环境走https://wemall-bloomagebiotech-api.bmjihuo.com，当然你也可以选择自己配置成需要的接口地址
  baseURL: getBaseUrl(),
  // process.env.NODE_ENV === 'development' ? '/' : 'https://wemall-bloomagebiotech-api.bmjihuo.com',
  //配后端数据的接收方式application/json;charset=UTF-8或者application/x-www-form-urlencoded;charset=UTF-8
  contentType: 'application/json;charset=UTF-8',
  //消息框消失时间
  messageDuration: 3000,
  //最长请求时间
  requestTimeout: 60000,
  //操作正常code，支持String、Array、int多种类型
  successCode: [200, 0],
  //登录失效code
  invalidCode: 402,
  //无权限code
  noPermissionCode: 401,
}
module.exports = network
